using Unity.Entities;
using Unity.Mathematics;

namespace DOTS
{
    public struct RandomSingleton : IComponentData
    {
        public Random Rand;
    }

    public class RandomSingletonAuthoring : MonoSingleton<RandomSingletonAuthoring>
    {
        public uint Seed;

        class Baker : Baker<RandomSingletonAuthoring>
        {
            public override void Bake(RandomSingletonAuthoring authoring)
            {
                var entity = GetEntity(TransformUsageFlags.None);
                AddComponent(entity, new RandomSingleton()
                {
                    Rand = new Random(authoring.Seed),
                });
            }
        }
    }
}